package main

import (
	"fmt"
	"gitee.com/lywtimer/practice-go/basic/structs"
	"gitee.com/lywtimer/practice-go/utils/queue"
)

func main() {
	fmt.Println("go语言仅支持封装，不支持继承和多态")
	fmt.Println("======= struct definition =======")
	var root structs.TreeNode
	fmt.Println(root)

	root = structs.TreeNode{Value: 3}
	root.Left = &structs.TreeNode{}
	root.Right = &structs.TreeNode{Value: 5}
	root.Right.Left = new(structs.TreeNode)
	root.Left.Right = structs.CreateNode(2)
	root.Right.Left.SetValue(4)
	fmt.Println(root)
	root.Right.Print()
	//需要改变内容使用指针接受者，结构过大考虑使用指针接受者
	fmt.Println("================")
	root.Traverse()
	nodeCount := 0
	root.TraverseFunc(func(node *structs.TreeNode) {
		nodeCount++
	})
	fmt.Println("一共多少个节点：", nodeCount)
	c := root.TraverseWithChannel()
	maxNode := 0
	for node := range c {
		if node.Value > maxNode {
			maxNode = node.Value
		}
	}
	fmt.Println("最大的节点：", maxNode)

	fmt.Println("================")
	myRoot := structs.MyTreeNode{Node: &root}
	myRoot.PostOrder()
	fmt.Println("======= queue =========")
	q := queue.Queue{}
	fmt.Println(q.IsEmpty())
	//fmt.Println(q.Pop())
}
